<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="https://cdn.staticfile.org/jquery/3.4.1/jquery.min.js"></script>
</head>
<body>
  <button id="btnGET">GET</button>
  <button id="btnPOST">POST</button>
  <button id="btnDELETE">DELETE</button>
  <button id="btnJSONP">JSONP</button>

  <script>
    $(function() {
      $('#btnGET').on('click', () => {
        $.ajax({
          url: 'http://127.0.0.1/api/get',
          type: 'GET',
          success: function(res) {
            console.log(res)
          }
        })
      })
    })
    $(function() {
      $('#btnPOST').on('click', () => {
        $.ajax({
          url: 'http://127.0.0.1/api/post',
          type: 'POST',
          data: {
            name: 'zhangsan',
            age: 18
          },
          success: function(res) {
            console.log(res)
          }
        })
      })
    })
    $(function() {
      $('#btnDELETE').on('click', () => {
        $.ajax({
          url: 'http://127.0.0.1/api/delete',
          type: 'DELETE',
          success: function(res) {
            console.log(res)
          }
        })
      })
    })
    $(function() {
      $('#btnJSONP').on('click', () => {
        $.ajax({
          url: 'http://127.0.0.1/api/jsonp',
          type: 'GET',
          dataType: 'jsonp',
          success: function(res) {
            console.log(res)
          }
        })
      })
    })
  </script>
</body>
</html>